home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / Event.cc,v < prev    next >
Text File  |  1989-05-04  |  2KB  |  139 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @@;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.34.20;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.48.41;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     88.10.30.13.04.23;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     88.09.28.22.13.20;  author grunwald;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 3.2
  35. log
  36. @Start using Gnu library heaps for schedulers
  37. @
  38. text
  39. @// This may look like C code, but it is really -*- C++ -*-
  40. // 
  41. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  42. //
  43. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  44. //
  45. #include "Event.h"
  46. #include "CpuMultiplexor.h"
  47. #include "Thread.h"
  48.  
  49. Event::~Event()
  50. {
  51.     lock.reserve();
  52.     assert( pPileOfThreads.isEmpty() );
  53.     lock.release();
  54. }
  55.  
  56. void
  57. Event::releaseAll()
  58. {
  59.     while ( ! pPileOfThreads.isEmpty() ) {
  60.     Thread *p = (Thread *) (pPileOfThreads.remove());
  61.     if (debugFlag) {
  62.         cerr << "Release " << *p << "\n";
  63.     }
  64.     ThisCpu -> add(p);
  65.     }
  66. }
  67.  
  68. void
  69. Event::trigger()
  70. {
  71.     lock.reserve();
  72.     generation++;
  73.     releaseAll();
  74.     lock.release();
  75. }
  76.  
  77. void
  78. Event::waitFor()
  79. {
  80.     lock.reserve();
  81.     int gen = generation;
  82.     lock.release();
  83.  
  84.     for (int i = 0; i < pLoops; i++) {
  85.     if (gen != generation) break;
  86.     }
  87.  
  88.     if (gen == generation) {
  89.     ThisCpu -> reserveByException( this );
  90.     }
  91. }
  92.  
  93. bool
  94. Event::reserveByException(Thread *byWho)
  95. {
  96.     lock.reserve();
  97.     pPileOfThreads.add( byWho );
  98.     lock.release();
  99.     return(TRUE);
  100. }
  101.  
  102. void
  103. Event::classPrintOn(ostream&)
  104. {
  105. }
  106. @
  107.  
  108.  
  109. 3.1
  110. log
  111. @Steay version
  112. @
  113. text
  114. @d63 5
  115. @
  116.  
  117.  
  118. 1.2
  119. log
  120. @*** empty log message ***
  121. @
  122. text
  123. @@
  124.  
  125.  
  126. 1.1
  127. log
  128. @Initial revision
  129. @
  130. text
  131. @d1 6
  132. d8 1
  133. a8 1
  134. #include "HardwareCpu.h"
  135. d26 1
  136. a26 1
  137.     ThisCpu -> add(p,0);
  138. @
  139.